/*
 * ER/Studio 7.1 SQL Code Generation
 * Company :      xxx
 * Project :      HistoriaLaboral080718.dm1
 * Author :       Miguel Zilli
 *
 * Date Created : Wednesday, August 06, 2008 19:01:19
 * Target DBMS : Microsoft SQL Server 2005
 */

IF OBJECT_ID('tArea_Cursos') IS NOT NULL
BEGIN
    DROP TABLE tArea_Cursos
    PRINT '<<< DROPPED TABLE tArea_Cursos >>>'
END
go
IF OBJECT_ID('tAreas') IS NOT NULL
BEGIN
    DROP TABLE tAreas
    PRINT '<<< DROPPED TABLE tAreas >>>'
END
go
IF OBJECT_ID('tBienes_x_Microemprendimiento') IS NOT NULL
BEGIN
    DROP TABLE tBienes_x_Microemprendimiento
    PRINT '<<< DROPPED TABLE tBienes_x_Microemprendimiento >>>'
END
go
IF OBJECT_ID('tCapacidad_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE tCapacidad_x_Persona
    PRINT '<<< DROPPED TABLE tCapacidad_x_Persona >>>'
END
go
IF OBJECT_ID('tCapacidades') IS NOT NULL
BEGIN
    DROP TABLE tCapacidades
    PRINT '<<< DROPPED TABLE tCapacidades >>>'
END
go
IF OBJECT_ID('tCargos') IS NOT NULL
BEGIN
    DROP TABLE tCargos
    PRINT '<<< DROPPED TABLE tCargos >>>'
END
go
IF OBJECT_ID('tCarnet') IS NOT NULL
BEGIN
    DROP TABLE tCarnet
    PRINT '<<< DROPPED TABLE tCarnet >>>'
END
go
IF OBJECT_ID('tCarnet_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE tCarnet_x_Persona
    PRINT '<<< DROPPED TABLE tCarnet_x_Persona >>>'
END
go
IF OBJECT_ID('tCobranzas') IS NOT NULL
BEGIN
    DROP TABLE tCobranzas
    PRINT '<<< DROPPED TABLE tCobranzas >>>'
END
go
IF OBJECT_ID('tConvenios') IS NOT NULL
BEGIN
    DROP TABLE tConvenios
    PRINT '<<< DROPPED TABLE tConvenios >>>'
END
go
IF OBJECT_ID('tCursos') IS NOT NULL
BEGIN
    DROP TABLE tCursos
    PRINT '<<< DROPPED TABLE tCursos >>>'
END
go
IF OBJECT_ID('tCursos_Deseados_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE tCursos_Deseados_x_Persona
    PRINT '<<< DROPPED TABLE tCursos_Deseados_x_Persona >>>'
END
go
IF OBJECT_ID('tCursos_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE tCursos_x_Persona
    PRINT '<<< DROPPED TABLE tCursos_x_Persona >>>'
END
go
IF OBJECT_ID('tDiscapacidad_x_Familiar') IS NOT NULL
BEGIN
    DROP TABLE tDiscapacidad_x_Familiar
    PRINT '<<< DROPPED TABLE tDiscapacidad_x_Familiar >>>'
END
go
IF OBJECT_ID('tDiscapacidad_x_Solicitud') IS NOT NULL
BEGIN
    DROP TABLE tDiscapacidad_x_Solicitud
    PRINT '<<< DROPPED TABLE tDiscapacidad_x_Solicitud >>>'
END
go
IF OBJECT_ID('tDiscapacidades') IS NOT NULL
BEGIN
    DROP TABLE tDiscapacidades
    PRINT '<<< DROPPED TABLE tDiscapacidades >>>'
END
go
IF OBJECT_ID('tDiscapacidades_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE tDiscapacidades_x_Persona
    PRINT '<<< DROPPED TABLE tDiscapacidades_x_Persona >>>'
END
go
IF OBJECT_ID('tEmpresas') IS NOT NULL
BEGIN
    DROP TABLE tEmpresas
    PRINT '<<< DROPPED TABLE tEmpresas >>>'
END
go
IF OBJECT_ID('tEstudio_x_Solicitud') IS NOT NULL
BEGIN
    DROP TABLE tEstudio_x_Solicitud
    PRINT '<<< DROPPED TABLE tEstudio_x_Solicitud >>>'
END
go
IF OBJECT_ID('tEstudios') IS NOT NULL
BEGIN
    DROP TABLE tEstudios
    PRINT '<<< DROPPED TABLE tEstudios >>>'
END
go
IF OBJECT_ID('tEtapas') IS NOT NULL
BEGIN
    DROP TABLE tEtapas
    PRINT '<<< DROPPED TABLE tEtapas >>>'
END
go
IF OBJECT_ID('tFamiliares') IS NOT NULL
BEGIN
    DROP TABLE tFamiliares
    PRINT '<<< DROPPED TABLE tFamiliares >>>'
END
go
IF OBJECT_ID('tIdioma_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE tIdioma_x_Persona
    PRINT '<<< DROPPED TABLE tIdioma_x_Persona >>>'
END
go
IF OBJECT_ID('tIdiomas') IS NOT NULL
BEGIN
    DROP TABLE tIdiomas
    PRINT '<<< DROPPED TABLE tIdiomas >>>'
END
go
IF OBJECT_ID('tIndustrias') IS NOT NULL
BEGIN
    DROP TABLE tIndustrias
    PRINT '<<< DROPPED TABLE tIndustrias >>>'
END
go
IF OBJECT_ID('tIntereses_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE tIntereses_x_Persona
    PRINT '<<< DROPPED TABLE tIntereses_x_Persona >>>'
END
go
IF OBJECT_ID('tMicroemprendimientos') IS NOT NULL
BEGIN
    DROP TABLE tMicroemprendimientos
    PRINT '<<< DROPPED TABLE tMicroemprendimientos >>>'
END
go
IF OBJECT_ID('tMunicipios') IS NOT NULL
BEGIN
    DROP TABLE tMunicipios
    PRINT '<<< DROPPED TABLE tMunicipios >>>'
END
go
IF OBJECT_ID('tPersonas') IS NOT NULL
BEGIN
    DROP TABLE tPersonas
    PRINT '<<< DROPPED TABLE tPersonas >>>'
END
go
IF OBJECT_ID('tPlan_x_Empresa') IS NOT NULL
BEGIN
    DROP TABLE tPlan_x_Empresa
    PRINT '<<< DROPPED TABLE tPlan_x_Empresa >>>'
END
go
IF OBJECT_ID('tPlan_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE tPlan_x_Persona
    PRINT '<<< DROPPED TABLE tPlan_x_Persona >>>'
END
go
IF OBJECT_ID('tPlanes') IS NOT NULL
BEGIN
    DROP TABLE tPlanes
    PRINT '<<< DROPPED TABLE tPlanes >>>'
END
go
IF OBJECT_ID('tSolicitudes') IS NOT NULL
BEGIN
    DROP TABLE tSolicitudes
    PRINT '<<< DROPPED TABLE tSolicitudes >>>'
END
go
IF OBJECT_ID('tTipo_Discapacidades') IS NOT NULL
BEGIN
    DROP TABLE tTipo_Discapacidades
    PRINT '<<< DROPPED TABLE tTipo_Discapacidades >>>'
END
go
IF OBJECT_ID('tTipo_Puestos') IS NOT NULL
BEGIN
    DROP TABLE tTipo_Puestos
    PRINT '<<< DROPPED TABLE tTipo_Puestos >>>'
END
go
IF OBJECT_ID('tTitulo_x_Persona') IS NOT NULL
BEGIN
    DROP TABLE tTitulo_x_Persona
    PRINT '<<< DROPPED TABLE tTitulo_x_Persona >>>'
END
go
IF OBJECT_ID('tTitulos') IS NOT NULL
BEGIN
    DROP TABLE tTitulos
    PRINT '<<< DROPPED TABLE tTitulos >>>'
END
go
IF OBJECT_ID('tTrabajos') IS NOT NULL
BEGIN
    DROP TABLE tTrabajos
    PRINT '<<< DROPPED TABLE tTrabajos >>>'
END
go
IF OBJECT_ID('tTrabajos_Domesticos') IS NOT NULL
BEGIN
    DROP TABLE tTrabajos_Domesticos
    PRINT '<<< DROPPED TABLE tTrabajos_Domesticos >>>'
END
go
IF OBJECT_ID('tUsuarios') IS NOT NULL
BEGIN
    DROP TABLE tUsuarios
    PRINT '<<< DROPPED TABLE tUsuarios >>>'
END
go
IF OBJECT_ID('tVisita_Solicitud') IS NOT NULL
BEGIN
    DROP TABLE tVisita_Solicitud
    PRINT '<<< DROPPED TABLE tVisita_Solicitud >>>'
END
go
IF OBJECT_ID('tVisitas') IS NOT NULL
BEGIN
    DROP TABLE tVisitas
    PRINT '<<< DROPPED TABLE tVisitas >>>'
END
go
/* 
 * TABLE: tArea_Cursos 
 */

CREATE TABLE tArea_Cursos(
    IdAreaCurso       int             IDENTITY(1,1),
    cNombre           varchar(255)    NULL,
    cObservaciones    text            NULL,
    CONSTRAINT IdAreaCurso PRIMARY KEY NONCLUSTERED (IdAreaCurso)
)
go



IF OBJECT_ID('tArea_Cursos') IS NOT NULL
    PRINT '<<< CREATED TABLE tArea_Cursos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tArea_Cursos >>>'
go

/* 
 * TABLE: tAreas 
 */

CREATE TABLE tAreas(
    IdAreas         int             IDENTITY(1,1),
    cNombre         varchar(255)    NULL,
    cDescripcion    varchar(255)    NULL,
    CONSTRAINT IdAreas PRIMARY KEY NONCLUSTERED (IdAreas)
)
go



IF OBJECT_ID('tAreas') IS NOT NULL
    PRINT '<<< CREATED TABLE tAreas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tAreas >>>'
go

/* 
 * TABLE: tBienes_x_Microemprendimiento 
 */

CREATE TABLE tBienes_x_Microemprendimiento(
    IdBienes                 int               IDENTITY(1,1),
    IdMicroemprendimiento    int               NULL,
    cCantidad                int               NULL,
    cMonto                   decimal(18, 2)    NULL,
    cEstado                  varchar(255)      NULL,
    cDescripcion             varchar(255)      NULL,
    CONSTRAINT IdBienes PRIMARY KEY NONCLUSTERED (IdBienes)
)
go



IF OBJECT_ID('tBienes_x_Microemprendimiento') IS NOT NULL
    PRINT '<<< CREATED TABLE tBienes_x_Microemprendimiento >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tBienes_x_Microemprendimiento >>>'
go

/* 
 * TABLE: tCapacidad_x_Persona 
 */

CREATE TABLE tCapacidad_x_Persona(
    IdCapacidad       int             NOT NULL,
    IdPersona         int             NOT NULL,
    cNivel            varchar(100)    NULL,
    cObservaciones    text            NULL,
    CONSTRAINT IdCapacidadIdPersona PRIMARY KEY NONCLUSTERED (IdCapacidad, IdPersona)
)
go



IF OBJECT_ID('tCapacidad_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE tCapacidad_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tCapacidad_x_Persona >>>'
go

/* 
 * TABLE: tCapacidades 
 */

CREATE TABLE tCapacidades(
    IdCapacidad     int             IDENTITY(1,1),
    cNombre         varchar(255)    NULL,
    cDescripcion    varchar(255)    NULL,
    CONSTRAINT IdCapacidad PRIMARY KEY NONCLUSTERED (IdCapacidad)
)
go



IF OBJECT_ID('tCapacidades') IS NOT NULL
    PRINT '<<< CREATED TABLE tCapacidades >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tCapacidades >>>'
go

/* 
 * TABLE: tCargos 
 */

CREATE TABLE tCargos(
    IdCargos        int             IDENTITY(1,1),
    cNombre         varchar(255)    NULL,
    cDescripcion    varchar(255)    NULL,
    IdTipoPuesto    int             NULL,
    CONSTRAINT IdCargos PRIMARY KEY NONCLUSTERED (IdCargos)
)
go



IF OBJECT_ID('tCargos') IS NOT NULL
    PRINT '<<< CREATED TABLE tCargos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tCargos >>>'
go

/* 
 * TABLE: tCarnet 
 */

CREATE TABLE tCarnet(
    IdCarnet          int             IDENTITY(1,1),
    cCnrt             varchar(20)     NULL,
    cCategoria        varchar(255)    NULL,
    cObservaciones    text            NULL,
    CONSTRAINT IdCarnet PRIMARY KEY NONCLUSTERED (IdCarnet)
)
go



IF OBJECT_ID('tCarnet') IS NOT NULL
    PRINT '<<< CREATED TABLE tCarnet >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tCarnet >>>'
go

/* 
 * TABLE: tCarnet_x_Persona 
 */

CREATE TABLE tCarnet_x_Persona(
    IdCarnet          int             NOT NULL,
    IdPersona         int             NOT NULL,
    cNumero           varchar(255)    NULL,
    cObservaciones    text            NULL,
    IdMunicipio       int             NULL,
    CONSTRAINT IdCarnetIdPersona PRIMARY KEY NONCLUSTERED (IdCarnet, IdPersona)
)
go



IF OBJECT_ID('tCarnet_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE tCarnet_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tCarnet_x_Persona >>>'
go

/* 
 * TABLE: tCobranzas 
 */

CREATE TABLE tCobranzas(
    IdCobranza               int               IDENTITY(1,1),
    cFecha                   datetime          NULL,
    cMonto                   decimal(18, 2)    NULL,
    cObservaciones           text              NULL,
    IdMicroemprendimiento    int               NULL,
    CONSTRAINT IdCobranza PRIMARY KEY NONCLUSTERED (IdCobranza)
)
go



IF OBJECT_ID('tCobranzas') IS NOT NULL
    PRINT '<<< CREATED TABLE tCobranzas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tCobranzas >>>'
go

/* 
 * TABLE: tConvenios 
 */

CREATE TABLE tConvenios(
    IdConvenio    int             IDENTITY(1,1),
    cEntidad      varchar(255)    NULL,
    cFecha        datetime        NULL,
    cDuracion     int             NULL,
    CONSTRAINT IdConvenio PRIMARY KEY NONCLUSTERED (IdConvenio)
)
go



IF OBJECT_ID('tConvenios') IS NOT NULL
    PRINT '<<< CREATED TABLE tConvenios >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tConvenios >>>'
go

/* 
 * TABLE: tCursos 
 */

CREATE TABLE tCursos(
    IdCurso           int             IDENTITY(1,1),
    cNombre           varchar(255)    NULL,
    cFechaInicio      datetime        NULL,
    cHorario          varchar(255)    NULL,
    cDuracion         int             NULL,
    cProfesor         varchar(255)    NULL,
    cCupo             int             NULL,
    cLugar            varchar(255)    NULL,
    cObservaciones    text            NULL,
    IdConvenio        int             NULL,
    IdAreaCurso       int             NULL,
    CONSTRAINT IdCurso PRIMARY KEY NONCLUSTERED (IdCurso)
)
go



IF OBJECT_ID('tCursos') IS NOT NULL
    PRINT '<<< CREATED TABLE tCursos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tCursos >>>'
go

/* 
 * TABLE: tCursos_Deseados_x_Persona 
 */

CREATE TABLE tCursos_Deseados_x_Persona(
    IdCurso           int     NOT NULL,
    IdPersona         int     NOT NULL,
    cObservaciones    text    NULL,
    CONSTRAINT IdCursoDeseasoIdPersona PRIMARY KEY NONCLUSTERED (IdCurso, IdPersona)
)
go



IF OBJECT_ID('tCursos_Deseados_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE tCursos_Deseados_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tCursos_Deseados_x_Persona >>>'
go

/* 
 * TABLE: tCursos_x_Persona 
 */

CREATE TABLE tCursos_x_Persona(
    IdCurso              int             NOT NULL,
    IdPersona            int             NOT NULL,
    cTitulo              varchar(255)    NULL,
    cEntidadEducativa    varchar(255)    NULL,
    cCompetencia         varchar(255)    NULL,
    cFechaInicio         datetime        NULL,
    cEstado              varchar(255)    NULL,
    CONSTRAINT IdCursoIdPersona PRIMARY KEY NONCLUSTERED (IdCurso, IdPersona)
)
go



IF OBJECT_ID('tCursos_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE tCursos_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tCursos_x_Persona >>>'
go

/* 
 * TABLE: tDiscapacidad_x_Familiar 
 */

CREATE TABLE tDiscapacidad_x_Familiar(
    IdDiscapacidad    int     NOT NULL,
    IdFamiliar        int     NOT NULL,
    cObservaciones    text    NULL,
    CONSTRAINT IdDiscapacidadIdFamiliar PRIMARY KEY NONCLUSTERED (IdDiscapacidad, IdFamiliar)
)
go



IF OBJECT_ID('tDiscapacidad_x_Familiar') IS NOT NULL
    PRINT '<<< CREATED TABLE tDiscapacidad_x_Familiar >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tDiscapacidad_x_Familiar >>>'
go

/* 
 * TABLE: tDiscapacidad_x_Solicitud 
 */

CREATE TABLE tDiscapacidad_x_Solicitud(
    IdDiscapacidad    int     NOT NULL,
    IdSolicitud       int     NOT NULL,
    cObservaciones    text    NULL,
    CONSTRAINT IdDiscapacidadIdSolicitud PRIMARY KEY NONCLUSTERED (IdDiscapacidad, IdSolicitud)
)
go



IF OBJECT_ID('tDiscapacidad_x_Solicitud') IS NOT NULL
    PRINT '<<< CREATED TABLE tDiscapacidad_x_Solicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tDiscapacidad_x_Solicitud >>>'
go

/* 
 * TABLE: tDiscapacidades 
 */

CREATE TABLE tDiscapacidades(
    IdDiscapacidad        int             IDENTITY(1,1),
    cNombre               varchar(255)    NULL,
    cObservaciones        text            NULL,
    IdTipoDiscapacidad    int             NULL,
    CONSTRAINT IdDiscapacidad PRIMARY KEY NONCLUSTERED (IdDiscapacidad)
)
go



IF OBJECT_ID('tDiscapacidades') IS NOT NULL
    PRINT '<<< CREATED TABLE tDiscapacidades >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tDiscapacidades >>>'
go

/* 
 * TABLE: tDiscapacidades_x_Persona 
 */

CREATE TABLE tDiscapacidades_x_Persona(
    IdDiscapacidad          int             NOT NULL,
    IdPersona               int             NOT NULL,
    cEntidadCertificante    varchar(255)    NULL,
    cVencimiento            datetime        NULL,
    cObservaciones          text            NULL,
    CONSTRAINT IdDiscapacidadIdPersona PRIMARY KEY NONCLUSTERED (IdDiscapacidad, IdPersona)
)
go



IF OBJECT_ID('tDiscapacidades_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE tDiscapacidades_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tDiscapacidades_x_Persona >>>'
go

/* 
 * TABLE: tEmpresas 
 */

CREATE TABLE tEmpresas(
    IdEmpresa            int             IDENTITY(1,1),
    cTamano              varchar(100)    NULL,
    cRazonSocial         varchar(255)    NULL,
    cDireccion           varchar(255)    NULL,
    cTelefono            varchar(100)    NULL,
    cEmail               varchar(100)    NULL,
    cContacto            varchar(255)    NULL,
    cTelefonoContacto    varchar(100)    NULL,
    cAgencia             varchar(100)    NULL,
    cBaja                varchar(20)     NULL,
    IdIndustria          int             NULL,
    IdMunicipio          int             NULL,
    CONSTRAINT IdEmpresa PRIMARY KEY NONCLUSTERED (IdEmpresa)
)
go



IF OBJECT_ID('tEmpresas') IS NOT NULL
    PRINT '<<< CREATED TABLE tEmpresas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tEmpresas >>>'
go

/* 
 * TABLE: tEstudio_x_Solicitud 
 */

CREATE TABLE tEstudio_x_Solicitud(
    IdTitulo          int     NOT NULL,
    IdSolicitud       int     NOT NULL,
    cObservaciones    text    NULL,
    CONSTRAINT IdTituloIdSolicitud PRIMARY KEY NONCLUSTERED (IdTitulo, IdSolicitud)
)
go



IF OBJECT_ID('tEstudio_x_Solicitud') IS NOT NULL
    PRINT '<<< CREATED TABLE tEstudio_x_Solicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tEstudio_x_Solicitud >>>'
go

/* 
 * TABLE: tEstudios 
 */

CREATE TABLE tEstudios(
    IdEstudio         int             IDENTITY(1,1),
    cNivel            varchar(100)    NULL,
    cObservaciones    text            NULL,
    CONSTRAINT IdEstudio PRIMARY KEY NONCLUSTERED (IdEstudio)
)
go



IF OBJECT_ID('tEstudios') IS NOT NULL
    PRINT '<<< CREATED TABLE tEstudios >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tEstudios >>>'
go

/* 
 * TABLE: tEtapas 
 */

CREATE TABLE tEtapas(
    IdEtapas                 int             IDENTITY(1,1),
    cNombre                  varchar(255)    NULL,
    cFechaEntrada            datetime        NULL,
    cFechaSalida             datetime        NULL,
    cEstado                  varchar(100)    NULL,
    cObservaciones           text            NULL,
    IdMicroemprendimiento    int             NULL,
    CONSTRAINT IdEtapas PRIMARY KEY NONCLUSTERED (IdEtapas)
)
go



IF OBJECT_ID('tEtapas') IS NOT NULL
    PRINT '<<< CREATED TABLE tEtapas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tEtapas >>>'
go

/* 
 * TABLE: tFamiliares 
 */

CREATE TABLE tFamiliares(
    IdFamiliar        int             IDENTITY(1,1),
    cNombre           varchar(255)    NULL,
    cApellido         varchar(255)    NULL,
    cParentesco       varchar(255)    NULL,
    cACargo           varchar(20)     NULL,
    cTrabaja          varchar(20)     NULL,
    cEstudia          varchar(20)     NULL,
    cEdad             int             NULL,
    cObservaciones    text            NULL,
    IdPersona         int             NULL,
    CONSTRAINT IdFamiliar PRIMARY KEY NONCLUSTERED (IdFamiliar)
)
go



IF OBJECT_ID('tFamiliares') IS NOT NULL
    PRINT '<<< CREATED TABLE tFamiliares >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tFamiliares >>>'
go

/* 
 * TABLE: tIdioma_x_Persona 
 */

CREATE TABLE tIdioma_x_Persona(
    IdIdioma          int             NOT NULL,
    IdPersona         int             NOT NULL,
    cOral             varchar(20)     NULL,
    cEscrito          varchar(20)     NULL,
    cNivel            varchar(100)    NULL,
    cObservaciones    text            NULL,
    CONSTRAINT IdIdiomaIdPersona PRIMARY KEY NONCLUSTERED (IdIdioma, IdPersona)
)
go



IF OBJECT_ID('tIdioma_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE tIdioma_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tIdioma_x_Persona >>>'
go

/* 
 * TABLE: tIdiomas 
 */

CREATE TABLE tIdiomas(
    IdIdioma          int             IDENTITY(1,1),
    cNombre           varchar(255)    NULL,
    cObservaciones    text            NULL,
    CONSTRAINT IdIdioma PRIMARY KEY NONCLUSTERED (IdIdioma)
)
go



IF OBJECT_ID('tIdiomas') IS NOT NULL
    PRINT '<<< CREATED TABLE tIdiomas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tIdiomas >>>'
go

/* 
 * TABLE: tIndustrias 
 */

CREATE TABLE tIndustrias(
    IdIndustria       int             IDENTITY(1,1),
    cNombre           varchar(255)    NULL,
    cObservaciones    text            NULL,
    CONSTRAINT IdIndustria PRIMARY KEY NONCLUSTERED (IdIndustria)
)
go



IF OBJECT_ID('tIndustrias') IS NOT NULL
    PRINT '<<< CREATED TABLE tIndustrias >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tIndustrias >>>'
go

/* 
 * TABLE: tIntereses_x_Persona 
 */

CREATE TABLE tIntereses_x_Persona(
    IdPersona         int     NOT NULL,
    IdAreas           int     NOT NULL,
    cObservaciones    text    NULL,
    CONSTRAINT IdPersonaIdAreas PRIMARY KEY NONCLUSTERED (IdPersona, IdAreas)
)
go



IF OBJECT_ID('tIntereses_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE tIntereses_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tIntereses_x_Persona >>>'
go

/* 
 * TABLE: tMicroemprendimientos 
 */

CREATE TABLE tMicroemprendimientos(
    IdMicroemprendimiento       int               IDENTITY(1,1),
    cNombre                     varchar(255)      NULL,
    cPropuesta                  varchar(255)      NULL,
    cFechaLanzamiento           datetime          NULL,
    cAntiguedad                 int               NULL,
    cDireccion                  varchar(255)      NULL,
    cSituacionDelTerreno        varchar(100)      NULL,
    cParticipantes              int               NULL,
    cParticipantesFamiliares    int               NULL,
    cAsistencia                 varchar(255)      NULL,
    cCapacitacion               varchar(255)      NULL,
    cDescripcionCapacitacion    varchar(255)      NULL,
    cMontoAsignado              decimal(18, 2)    NULL,
    cFirmaConvenio              datetime          NULL,
    cFechaTransferencia         datetime          NULL,
    cPlanCuotas                 int               NULL,
    cPromedioFacturacion        decimal(18, 2)    NULL,
    IdMunicipio                 int               NULL,
    IdIndustria                 int               NULL,
    IdPersona                   int               NULL,
    CONSTRAINT IdMicroemprendimiento PRIMARY KEY NONCLUSTERED (IdMicroemprendimiento)
)
go



IF OBJECT_ID('tMicroemprendimientos') IS NOT NULL
    PRINT '<<< CREATED TABLE tMicroemprendimientos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tMicroemprendimientos >>>'
go

/* 
 * TABLE: tMunicipios 
 */

CREATE TABLE tMunicipios(
    IdMunicipio    int             IDENTITY(1,1),
    cNombre        varchar(255)    NULL,
    cCodigo        varchar(100)    NULL,
    CONSTRAINT IdMunicipio PRIMARY KEY NONCLUSTERED (IdMunicipio)
)
go



IF OBJECT_ID('tMunicipios') IS NOT NULL
    PRINT '<<< CREATED TABLE tMunicipios >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tMunicipios >>>'
go

/* 
 * TABLE: tPersonas 
 */

CREATE TABLE tPersonas(
    IdPersona             int             IDENTITY(1,1),
    cTipoDocumento        varchar(100)    NULL,
    cNumeroDocumento      int             NULL,
    cNombre               varchar(255)    NULL,
    cOficio               varchar(255)    NULL,
    cApellido             varchar(255)    NULL,
    cDomicilioReal        varchar(255)    NULL,
    cDomicilioActual      varchar(255)    NULL,
    cSexo                 varchar(20)     NULL,
    cFechaNacimiento      datetime        NULL,
    cEstadoCivil          varchar(255)    NULL,
    cCuil                 varchar(100)    NULL,
    cCuit                 varchar(100)    NULL,
    cTelefono             varchar(100)    NULL,
    cEmail                varchar(100)    NULL,
    cVivienda             varchar(255)    NULL,
    cCloaca               varchar(20)     NULL,
    cAgua                 varchar(20)     NULL,
    cAsistenciaMedica     varchar(255)    NULL,
    cVehiculo             varchar(20)     NULL,
    cMovilidad            varchar(20)     NULL,
    cViajar               varchar(20)     NULL,
    cBuscaTrabajo         varchar(20)     NULL,
    cEstadoLaboral        varchar(20)     NULL,
    cPension              varchar(255)    NULL,
    cBaja                 varchar(20)     NULL,
    cObservaciones        text            NULL,
    cEmpleadoDomestico    varchar(20)     NULL,
    IdMunicipio           int             NULL,
    CONSTRAINT IdPersona PRIMARY KEY NONCLUSTERED (IdPersona)
)
go



IF OBJECT_ID('tPersonas') IS NOT NULL
    PRINT '<<< CREATED TABLE tPersonas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tPersonas >>>'
go

/* 
 * TABLE: tPlan_x_Empresa 
 */

CREATE TABLE tPlan_x_Empresa(
    IdPlan              int         NOT NULL,
    IdEmpresa           int         NOT NULL,
    cParticipantes      int         NULL,
    cFechaSolicitud     datetime    NULL,
    cFechaAsignacion    datetime    NULL,
    cObservaciones      text        NULL,
    CONSTRAINT IdPlanIdEmpresa PRIMARY KEY NONCLUSTERED (IdPlan, IdEmpresa)
)
go



IF OBJECT_ID('tPlan_x_Empresa') IS NOT NULL
    PRINT '<<< CREATED TABLE tPlan_x_Empresa >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tPlan_x_Empresa >>>'
go

/* 
 * TABLE: tPlan_x_Persona 
 */

CREATE TABLE tPlan_x_Persona(
    IdPlan                      int             NOT NULL,
    IdPersona                   int             NOT NULL,
    cFechaAdjudicacion          datetime        NULL,
    cFechaBaja                  datetime        NULL,
    cContraprestacion           varchar(255)    NULL,
    cLugarDeContraprestacion    varchar(255)    NULL,
    cObservaciones              text            NULL,
    CONSTRAINT IdPlanIdPersona PRIMARY KEY NONCLUSTERED (IdPlan, IdPersona)
)
go



IF OBJECT_ID('tPlan_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE tPlan_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tPlan_x_Persona >>>'
go

/* 
 * TABLE: tPlanes 
 */

CREATE TABLE tPlanes(
    IdPlan          int             IDENTITY(1,1),
    cAlcance        varchar(100)    NULL,
    cNombre         varchar(255)    NULL,
    cDescripcion    varchar(255)    NULL,
    CONSTRAINT IdPlan PRIMARY KEY NONCLUSTERED (IdPlan)
)
go



IF OBJECT_ID('tPlanes') IS NOT NULL
    PRINT '<<< CREATED TABLE tPlanes >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tPlanes >>>'
go

/* 
 * TABLE: tSolicitudes 
 */

CREATE TABLE tSolicitudes(
    IdSolicitud             int               IDENTITY(1,1),
    cConvenioLaboral        varchar(255)      NULL,
    cFechaSolicitud         datetime          NULL,
    cTiempoTrabajo          varchar(255)      NULL,
    cSexo                   varchar(20)       NULL,
    cCantidadPuestos        int               NULL,
    cEdadMinima             int               NULL,
    cEdadMaxima             int               NULL,
    cTareasARealizar        varchar(255)      NULL,
    cUbicacionTrabajo       varchar(255)      NULL,
    cSalario                decimal(18, 2)    NULL,
    cBeneficios             varchar(255)      NULL,
    cDireccionEntrevista    varchar(255)      NULL,
    cContacto               varchar(255)      NULL,
    cFormaContrato          varchar(255)      NULL,
    cObservacionesOferta    text              NULL,
    cObservaciones          text              NULL,
    IdAreas                 int               NULL,
    IdMunicipio             int               NULL,
    IdCargos                int               NULL,
    IdEmpresa               int               NULL,
    CONSTRAINT IdSolicitud PRIMARY KEY NONCLUSTERED (IdSolicitud)
)
go



IF OBJECT_ID('tSolicitudes') IS NOT NULL
    PRINT '<<< CREATED TABLE tSolicitudes >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tSolicitudes >>>'
go

/* 
 * TABLE: tTipo_Discapacidades 
 */

CREATE TABLE tTipo_Discapacidades(
    IdTipoDiscapacidad    int             IDENTITY(1,1),
    cNombre               varchar(255)    NULL,
    cObservaciones        text            NULL,
    CONSTRAINT IdTipoDiscapacidad PRIMARY KEY NONCLUSTERED (IdTipoDiscapacidad)
)
go



IF OBJECT_ID('tTipo_Discapacidades') IS NOT NULL
    PRINT '<<< CREATED TABLE tTipo_Discapacidades >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tTipo_Discapacidades >>>'
go

/* 
 * TABLE: tTipo_Puestos 
 */

CREATE TABLE tTipo_Puestos(
    IdTipoPuesto    int             IDENTITY(1,1),
    cNombre         varchar(255)    NULL,
    cDescripcion    varchar(255)    NULL,
    CONSTRAINT IdTipoPuesto PRIMARY KEY NONCLUSTERED (IdTipoPuesto)
)
go



IF OBJECT_ID('tTipo_Puestos') IS NOT NULL
    PRINT '<<< CREATED TABLE tTipo_Puestos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tTipo_Puestos >>>'
go

/* 
 * TABLE: tTitulo_x_Persona 
 */

CREATE TABLE tTitulo_x_Persona(
    IdTitulo             int             NOT NULL,
    IdPersona            int             NOT NULL,
    cEntidadEducativa    varchar(255)    NULL,
    cFechaIngreso        datetime        NULL,
    cFechaEgreso         datetime        NULL,
    cCompleto            varchar(20)     NULL,
    CONSTRAINT IdTituloIdPersona PRIMARY KEY NONCLUSTERED (IdTitulo, IdPersona)
)
go



IF OBJECT_ID('tTitulo_x_Persona') IS NOT NULL
    PRINT '<<< CREATED TABLE tTitulo_x_Persona >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tTitulo_x_Persona >>>'
go

/* 
 * TABLE: tTitulos 
 */

CREATE TABLE tTitulos(
    IdTitulo         int             IDENTITY(1,1),
    IdEstudio        int             NULL,
    cNombre          varchar(255)    NULL,
    cCompetencias    varchar(255)    NULL,
    CONSTRAINT IdTitulo PRIMARY KEY NONCLUSTERED (IdTitulo)
)
go



IF OBJECT_ID('tTitulos') IS NOT NULL
    PRINT '<<< CREATED TABLE tTitulos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tTitulos >>>'
go

/* 
 * TABLE: tTrabajos 
 */

CREATE TABLE tTrabajos(
    IdTrabajo           int             IDENTITY(1,1),
    IdPersona           int             NULL,
    IdEmpresa           int             NULL,
    IdCargos            int             NULL,
    cFechaInicio        datetime        NULL,
    cFechaFin           datetime        NULL,
    cTareasARealizar    varchar(255)    NULL,
    cFuente             varchar(100)    NULL,
    cEstado             varchar(100)    NULL,
    cObservaciones      text            NULL,
    IdAreas             int             NULL,
    IdSolicitud         int             NULL,
    CONSTRAINT IdTrabajo PRIMARY KEY NONCLUSTERED (IdTrabajo)
)
go



IF OBJECT_ID('tTrabajos') IS NOT NULL
    PRINT '<<< CREATED TABLE tTrabajos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tTrabajos >>>'
go

/* 
 * TABLE: tTrabajos_Domesticos 
 */

CREATE TABLE tTrabajos_Domesticos(
    IdTrabajoDomestico    int               IDENTITY(1,1),
    cCUIL                 varchar(100)      NULL,
    cEmpleador            varchar(255)      NULL,
    cDomicilio            varchar(255)      NULL,
    cFechaIngreso         datetime          NULL,
    cFechaEgreso          datetime          NULL,
    cRemuneracion         decimal(18, 2)    NULL,
    cCategoria            varchar(255)      NULL,
    cActividad            varchar(255)      NULL,
    cAgencia              varchar(20)       NULL,
    cEstado               datetime          NULL,
    IdPersona             int               NULL,
    IdEmpresa             int               NULL,
    CONSTRAINT IdTrabajoDomestico PRIMARY KEY NONCLUSTERED (IdTrabajoDomestico)
)
go



IF OBJECT_ID('tTrabajos_Domesticos') IS NOT NULL
    PRINT '<<< CREATED TABLE tTrabajos_Domesticos >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tTrabajos_Domesticos >>>'
go

/* 
 * TABLE: tUsuarios 
 */

CREATE TABLE tUsuarios(
    idUsuario         int             IDENTITY(1,1),
    cNombre           varchar(100)    NULL,
    cPassword         varchar(20)     NULL,
    cPersmisos        int             NULL,
    cObservaciones    varchar(255)    NULL,
    IdMunicipio       int             NULL,
    CONSTRAINT IdUsuario PRIMARY KEY NONCLUSTERED (idUsuario)
)
go



IF OBJECT_ID('tUsuarios') IS NOT NULL
    PRINT '<<< CREATED TABLE tUsuarios >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tUsuarios >>>'
go

/* 
 * TABLE: tVisita_Solicitud 
 */

CREATE TABLE tVisita_Solicitud(
    IdVisitasSolicitud    int             IDENTITY(1,1),
    cRazonVisita          varchar(255)    NULL,
    cFechaProgramada      datetime        NULL,
    cFechaVisita          datetime        NULL,
    cObservaciones        text            NULL,
    IdSolicitud           int             NULL,
    IdEmpresa             int             NULL,
    CONSTRAINT IdVisitasSolicitud PRIMARY KEY NONCLUSTERED (IdVisitasSolicitud)
)
go



IF OBJECT_ID('tVisita_Solicitud') IS NOT NULL
    PRINT '<<< CREATED TABLE tVisita_Solicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tVisita_Solicitud >>>'
go

/* 
 * TABLE: tVisitas 
 */

CREATE TABLE tVisitas(
    IdVisita            int             IDENTITY(1,1),
    cVisitador          varchar(255)    NULL,
    cFechaProgramada    datetime        NULL,
    cFechaVisita        datetime        NULL,
    cEstado             varchar(100)    NULL,
    cObservaciones      text            NULL,
    IdEtapas            int             NULL,
    CONSTRAINT IdVista PRIMARY KEY NONCLUSTERED (IdVisita)
)
go



IF OBJECT_ID('tVisitas') IS NOT NULL
    PRINT '<<< CREATED TABLE tVisitas >>>'
ELSE
    PRINT '<<< FAILED CREATING TABLE tVisitas >>>'
go

/* 
 * INDEX: IdMicroemprendimiento 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tBienes_x_Microemprendimiento') AND name='IdMicroemprendimiento')
BEGIN
    DROP INDEX tBienes_x_Microemprendimiento.IdMicroemprendimiento
    PRINT '<<< DROPPED INDEX tBienes_x_Microemprendimiento.IdMicroemprendimiento >>>'
END
go

/* 
 * INDEX: IdMicroemprendimiento 
 */

CREATE INDEX IdMicroemprendimiento ON tBienes_x_Microemprendimiento(IdMicroemprendimiento)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tBienes_x_Microemprendimiento') AND name='IdMicroemprendimiento')
    PRINT '<<< CREATED INDEX tBienes_x_Microemprendimiento.IdMicroemprendimiento >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tBienes_x_Microemprendimiento.IdMicroemprendimiento >>>'
go

/* 
 * INDEX: IdCapacidad 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCapacidad_x_Persona') AND name='IdCapacidad')
BEGIN
    DROP INDEX tCapacidad_x_Persona.IdCapacidad
    PRINT '<<< DROPPED INDEX tCapacidad_x_Persona.IdCapacidad >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCapacidad_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX tCapacidad_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX tCapacidad_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdCapacidad 
 */

CREATE INDEX IdCapacidad ON tCapacidad_x_Persona(IdCapacidad)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCapacidad_x_Persona') AND name='IdCapacidad')
    PRINT '<<< CREATED INDEX tCapacidad_x_Persona.IdCapacidad >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCapacidad_x_Persona.IdCapacidad >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tCapacidad_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCapacidad_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tCapacidad_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCapacidad_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdTipoPuesto 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCargos') AND name='IdTipoPuesto')
BEGIN
    DROP INDEX tCargos.IdTipoPuesto
    PRINT '<<< DROPPED INDEX tCargos.IdTipoPuesto >>>'
END
go

/* 
 * INDEX: IdTipoPuesto 
 */

CREATE INDEX IdTipoPuesto ON tCargos(IdTipoPuesto)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCargos') AND name='IdTipoPuesto')
    PRINT '<<< CREATED INDEX tCargos.IdTipoPuesto >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCargos.IdTipoPuesto >>>'
go

/* 
 * INDEX: IdCarnet 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCarnet_x_Persona') AND name='IdCarnet')
BEGIN
    DROP INDEX tCarnet_x_Persona.IdCarnet
    PRINT '<<< DROPPED INDEX tCarnet_x_Persona.IdCarnet >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCarnet_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX tCarnet_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX tCarnet_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdCarnet 
 */

CREATE INDEX IdCarnet ON tCarnet_x_Persona(IdCarnet)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCarnet_x_Persona') AND name='IdCarnet')
    PRINT '<<< CREATED INDEX tCarnet_x_Persona.IdCarnet >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCarnet_x_Persona.IdCarnet >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tCarnet_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCarnet_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tCarnet_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCarnet_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdMicroemprendimiento 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCobranzas') AND name='IdMicroemprendimiento')
BEGIN
    DROP INDEX tCobranzas.IdMicroemprendimiento
    PRINT '<<< DROPPED INDEX tCobranzas.IdMicroemprendimiento >>>'
END
go

/* 
 * INDEX: IdMicroemprendimiento 
 */

CREATE INDEX IdMicroemprendimiento ON tCobranzas(IdMicroemprendimiento)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCobranzas') AND name='IdMicroemprendimiento')
    PRINT '<<< CREATED INDEX tCobranzas.IdMicroemprendimiento >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCobranzas.IdMicroemprendimiento >>>'
go

/* 
 * INDEX: IdAreaCurso 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos') AND name='IdAreaCurso')
BEGIN
    DROP INDEX tCursos.IdAreaCurso
    PRINT '<<< DROPPED INDEX tCursos.IdAreaCurso >>>'
END
go

/* 
 * INDEX: IdConvenio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos') AND name='IdConvenio')
BEGIN
    DROP INDEX tCursos.IdConvenio
    PRINT '<<< DROPPED INDEX tCursos.IdConvenio >>>'
END
go

/* 
 * INDEX: IdAreaCurso 
 */

CREATE INDEX IdAreaCurso ON tCursos(IdAreaCurso)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos') AND name='IdAreaCurso')
    PRINT '<<< CREATED INDEX tCursos.IdAreaCurso >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCursos.IdAreaCurso >>>'
go

/* 
 * INDEX: IdConvenio 
 */

CREATE INDEX IdConvenio ON tCursos(IdConvenio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos') AND name='IdConvenio')
    PRINT '<<< CREATED INDEX tCursos.IdConvenio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCursos.IdConvenio >>>'
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos_Deseados_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX tCursos_Deseados_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX tCursos_Deseados_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdCurso 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos_Deseados_x_Persona') AND name='IdCurso')
BEGIN
    DROP INDEX tCursos_Deseados_x_Persona.IdCurso
    PRINT '<<< DROPPED INDEX tCursos_Deseados_x_Persona.IdCurso >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tCursos_Deseados_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos_Deseados_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tCursos_Deseados_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCursos_Deseados_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdCurso 
 */

CREATE INDEX IdCurso ON tCursos_Deseados_x_Persona(IdCurso)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos_Deseados_x_Persona') AND name='IdCurso')
    PRINT '<<< CREATED INDEX tCursos_Deseados_x_Persona.IdCurso >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCursos_Deseados_x_Persona.IdCurso >>>'
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX tCursos_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX tCursos_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdCurso 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos_x_Persona') AND name='IdCurso')
BEGIN
    DROP INDEX tCursos_x_Persona.IdCurso
    PRINT '<<< DROPPED INDEX tCursos_x_Persona.IdCurso >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tCursos_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tCursos_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCursos_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdCurso 
 */

CREATE INDEX IdCurso ON tCursos_x_Persona(IdCurso)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tCursos_x_Persona') AND name='IdCurso')
    PRINT '<<< CREATED INDEX tCursos_x_Persona.IdCurso >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tCursos_x_Persona.IdCurso >>>'
go

/* 
 * INDEX: IdDiscapacidad 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidad_x_Familiar') AND name='IdDiscapacidad')
BEGIN
    DROP INDEX tDiscapacidad_x_Familiar.IdDiscapacidad
    PRINT '<<< DROPPED INDEX tDiscapacidad_x_Familiar.IdDiscapacidad >>>'
END
go

/* 
 * INDEX: IDFamiliar 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidad_x_Familiar') AND name='IDFamiliar')
BEGIN
    DROP INDEX tDiscapacidad_x_Familiar.IDFamiliar
    PRINT '<<< DROPPED INDEX tDiscapacidad_x_Familiar.IDFamiliar >>>'
END
go

/* 
 * INDEX: IdDiscapacidad 
 */

CREATE INDEX IdDiscapacidad ON tDiscapacidad_x_Familiar(IdDiscapacidad)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidad_x_Familiar') AND name='IdDiscapacidad')
    PRINT '<<< CREATED INDEX tDiscapacidad_x_Familiar.IdDiscapacidad >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tDiscapacidad_x_Familiar.IdDiscapacidad >>>'
go

/* 
 * INDEX: IDFamiliar 
 */

CREATE INDEX IDFamiliar ON tDiscapacidad_x_Familiar(IdFamiliar)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidad_x_Familiar') AND name='IDFamiliar')
    PRINT '<<< CREATED INDEX tDiscapacidad_x_Familiar.IDFamiliar >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tDiscapacidad_x_Familiar.IDFamiliar >>>'
go

/* 
 * INDEX: IdDiscapacidad 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidad_x_Solicitud') AND name='IdDiscapacidad')
BEGIN
    DROP INDEX tDiscapacidad_x_Solicitud.IdDiscapacidad
    PRINT '<<< DROPPED INDEX tDiscapacidad_x_Solicitud.IdDiscapacidad >>>'
END
go

/* 
 * INDEX: IdSolicitud 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidad_x_Solicitud') AND name='IdSolicitud')
BEGIN
    DROP INDEX tDiscapacidad_x_Solicitud.IdSolicitud
    PRINT '<<< DROPPED INDEX tDiscapacidad_x_Solicitud.IdSolicitud >>>'
END
go

/* 
 * INDEX: IdDiscapacidad 
 */

CREATE INDEX IdDiscapacidad ON tDiscapacidad_x_Solicitud(IdDiscapacidad)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidad_x_Solicitud') AND name='IdDiscapacidad')
    PRINT '<<< CREATED INDEX tDiscapacidad_x_Solicitud.IdDiscapacidad >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tDiscapacidad_x_Solicitud.IdDiscapacidad >>>'
go

/* 
 * INDEX: IdSolicitud 
 */

CREATE INDEX IdSolicitud ON tDiscapacidad_x_Solicitud(IdSolicitud)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidad_x_Solicitud') AND name='IdSolicitud')
    PRINT '<<< CREATED INDEX tDiscapacidad_x_Solicitud.IdSolicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tDiscapacidad_x_Solicitud.IdSolicitud >>>'
go

/* 
 * INDEX: IdTipoDiscapacidad 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidades') AND name='IdTipoDiscapacidad')
BEGIN
    DROP INDEX tDiscapacidades.IdTipoDiscapacidad
    PRINT '<<< DROPPED INDEX tDiscapacidades.IdTipoDiscapacidad >>>'
END
go

/* 
 * INDEX: IdTipoDiscapacidad 
 */

CREATE INDEX IdTipoDiscapacidad ON tDiscapacidades(IdTipoDiscapacidad)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidades') AND name='IdTipoDiscapacidad')
    PRINT '<<< CREATED INDEX tDiscapacidades.IdTipoDiscapacidad >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tDiscapacidades.IdTipoDiscapacidad >>>'
go

/* 
 * INDEX: IdDiscapacidad 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidades_x_Persona') AND name='IdDiscapacidad')
BEGIN
    DROP INDEX tDiscapacidades_x_Persona.IdDiscapacidad
    PRINT '<<< DROPPED INDEX tDiscapacidades_x_Persona.IdDiscapacidad >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidades_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX tDiscapacidades_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX tDiscapacidades_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdDiscapacidad 
 */

CREATE INDEX IdDiscapacidad ON tDiscapacidades_x_Persona(IdDiscapacidad)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidades_x_Persona') AND name='IdDiscapacidad')
    PRINT '<<< CREATED INDEX tDiscapacidades_x_Persona.IdDiscapacidad >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tDiscapacidades_x_Persona.IdDiscapacidad >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tDiscapacidades_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tDiscapacidades_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tDiscapacidades_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tDiscapacidades_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdMunicipio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tEmpresas') AND name='IdMunicipio')
BEGIN
    DROP INDEX tEmpresas.IdMunicipio
    PRINT '<<< DROPPED INDEX tEmpresas.IdMunicipio >>>'
END
go

/* 
 * INDEX: IdIndustria 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tEmpresas') AND name='IdIndustria')
BEGIN
    DROP INDEX tEmpresas.IdIndustria
    PRINT '<<< DROPPED INDEX tEmpresas.IdIndustria >>>'
END
go

/* 
 * INDEX: IdMunicipio 
 */

CREATE INDEX IdMunicipio ON tEmpresas(IdMunicipio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tEmpresas') AND name='IdMunicipio')
    PRINT '<<< CREATED INDEX tEmpresas.IdMunicipio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tEmpresas.IdMunicipio >>>'
go

/* 
 * INDEX: IdIndustria 
 */

CREATE INDEX IdIndustria ON tEmpresas(IdIndustria)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tEmpresas') AND name='IdIndustria')
    PRINT '<<< CREATED INDEX tEmpresas.IdIndustria >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tEmpresas.IdIndustria >>>'
go

/* 
 * INDEX: IdTitulo 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tEstudio_x_Solicitud') AND name='IdTitulo')
BEGIN
    DROP INDEX tEstudio_x_Solicitud.IdTitulo
    PRINT '<<< DROPPED INDEX tEstudio_x_Solicitud.IdTitulo >>>'
END
go

/* 
 * INDEX: IdSolicitud 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tEstudio_x_Solicitud') AND name='IdSolicitud')
BEGIN
    DROP INDEX tEstudio_x_Solicitud.IdSolicitud
    PRINT '<<< DROPPED INDEX tEstudio_x_Solicitud.IdSolicitud >>>'
END
go

/* 
 * INDEX: IdTitulo 
 */

CREATE INDEX IdTitulo ON tEstudio_x_Solicitud(IdTitulo)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tEstudio_x_Solicitud') AND name='IdTitulo')
    PRINT '<<< CREATED INDEX tEstudio_x_Solicitud.IdTitulo >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tEstudio_x_Solicitud.IdTitulo >>>'
go

/* 
 * INDEX: IdSolicitud 
 */

CREATE INDEX IdSolicitud ON tEstudio_x_Solicitud(IdSolicitud)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tEstudio_x_Solicitud') AND name='IdSolicitud')
    PRINT '<<< CREATED INDEX tEstudio_x_Solicitud.IdSolicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tEstudio_x_Solicitud.IdSolicitud >>>'
go

/* 
 * INDEX: IdMicroemprendimiento 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tEtapas') AND name='IdMicroemprendimiento')
BEGIN
    DROP INDEX tEtapas.IdMicroemprendimiento
    PRINT '<<< DROPPED INDEX tEtapas.IdMicroemprendimiento >>>'
END
go

/* 
 * INDEX: IdMicroemprendimiento 
 */

CREATE INDEX IdMicroemprendimiento ON tEtapas(IdMicroemprendimiento)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tEtapas') AND name='IdMicroemprendimiento')
    PRINT '<<< CREATED INDEX tEtapas.IdMicroemprendimiento >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tEtapas.IdMicroemprendimiento >>>'
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tFamiliares') AND name='IdPersona')
BEGIN
    DROP INDEX tFamiliares.IdPersona
    PRINT '<<< DROPPED INDEX tFamiliares.IdPersona >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tFamiliares(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tFamiliares') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tFamiliares.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tFamiliares.IdPersona >>>'
go

/* 
 * INDEX: IdIdioma 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tIdioma_x_Persona') AND name='IdIdioma')
BEGIN
    DROP INDEX tIdioma_x_Persona.IdIdioma
    PRINT '<<< DROPPED INDEX tIdioma_x_Persona.IdIdioma >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tIdioma_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX tIdioma_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX tIdioma_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdIdioma 
 */

CREATE INDEX IdIdioma ON tIdioma_x_Persona(IdIdioma)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tIdioma_x_Persona') AND name='IdIdioma')
    PRINT '<<< CREATED INDEX tIdioma_x_Persona.IdIdioma >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tIdioma_x_Persona.IdIdioma >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tIdioma_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tIdioma_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tIdioma_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tIdioma_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdAreas 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tIntereses_x_Persona') AND name='IdAreas')
BEGIN
    DROP INDEX tIntereses_x_Persona.IdAreas
    PRINT '<<< DROPPED INDEX tIntereses_x_Persona.IdAreas >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tIntereses_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX tIntereses_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX tIntereses_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdAreas 
 */

CREATE INDEX IdAreas ON tIntereses_x_Persona(IdAreas)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tIntereses_x_Persona') AND name='IdAreas')
    PRINT '<<< CREATED INDEX tIntereses_x_Persona.IdAreas >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tIntereses_x_Persona.IdAreas >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tIntereses_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tIntereses_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tIntereses_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tIntereses_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdMunicipio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tMicroemprendimientos') AND name='IdMunicipio')
BEGIN
    DROP INDEX tMicroemprendimientos.IdMunicipio
    PRINT '<<< DROPPED INDEX tMicroemprendimientos.IdMunicipio >>>'
END
go

/* 
 * INDEX: IdIndustria 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tMicroemprendimientos') AND name='IdIndustria')
BEGIN
    DROP INDEX tMicroemprendimientos.IdIndustria
    PRINT '<<< DROPPED INDEX tMicroemprendimientos.IdIndustria >>>'
END
go

/* 
 * INDEX: IdPesona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tMicroemprendimientos') AND name='IdPesona')
BEGIN
    DROP INDEX tMicroemprendimientos.IdPesona
    PRINT '<<< DROPPED INDEX tMicroemprendimientos.IdPesona >>>'
END
go

/* 
 * INDEX: IdMunicipio 
 */

CREATE INDEX IdMunicipio ON tMicroemprendimientos(IdMunicipio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tMicroemprendimientos') AND name='IdMunicipio')
    PRINT '<<< CREATED INDEX tMicroemprendimientos.IdMunicipio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tMicroemprendimientos.IdMunicipio >>>'
go

/* 
 * INDEX: IdIndustria 
 */

CREATE INDEX IdIndustria ON tMicroemprendimientos(IdIndustria)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tMicroemprendimientos') AND name='IdIndustria')
    PRINT '<<< CREATED INDEX tMicroemprendimientos.IdIndustria >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tMicroemprendimientos.IdIndustria >>>'
go

/* 
 * INDEX: IdPesona 
 */

CREATE INDEX IdPesona ON tMicroemprendimientos(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tMicroemprendimientos') AND name='IdPesona')
    PRINT '<<< CREATED INDEX tMicroemprendimientos.IdPesona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tMicroemprendimientos.IdPesona >>>'
go

/* 
 * INDEX: IdMunicipio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tPersonas') AND name='IdMunicipio')
BEGIN
    DROP INDEX tPersonas.IdMunicipio
    PRINT '<<< DROPPED INDEX tPersonas.IdMunicipio >>>'
END
go

/* 
 * INDEX: IdMunicipio 
 */

CREATE INDEX IdMunicipio ON tPersonas(IdMunicipio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tPersonas') AND name='IdMunicipio')
    PRINT '<<< CREATED INDEX tPersonas.IdMunicipio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tPersonas.IdMunicipio >>>'
go

/* 
 * INDEX: IdPlan 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tPlan_x_Empresa') AND name='IdPlan')
BEGIN
    DROP INDEX tPlan_x_Empresa.IdPlan
    PRINT '<<< DROPPED INDEX tPlan_x_Empresa.IdPlan >>>'
END
go

/* 
 * INDEX: IdEmpresa 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tPlan_x_Empresa') AND name='IdEmpresa')
BEGIN
    DROP INDEX tPlan_x_Empresa.IdEmpresa
    PRINT '<<< DROPPED INDEX tPlan_x_Empresa.IdEmpresa >>>'
END
go

/* 
 * INDEX: IdPlan 
 */

CREATE INDEX IdPlan ON tPlan_x_Empresa(IdPlan)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tPlan_x_Empresa') AND name='IdPlan')
    PRINT '<<< CREATED INDEX tPlan_x_Empresa.IdPlan >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tPlan_x_Empresa.IdPlan >>>'
go

/* 
 * INDEX: IdEmpresa 
 */

CREATE INDEX IdEmpresa ON tPlan_x_Empresa(IdEmpresa)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tPlan_x_Empresa') AND name='IdEmpresa')
    PRINT '<<< CREATED INDEX tPlan_x_Empresa.IdEmpresa >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tPlan_x_Empresa.IdEmpresa >>>'
go

/* 
 * INDEX: IdPlan 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tPlan_x_Persona') AND name='IdPlan')
BEGIN
    DROP INDEX tPlan_x_Persona.IdPlan
    PRINT '<<< DROPPED INDEX tPlan_x_Persona.IdPlan >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tPlan_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX tPlan_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX tPlan_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdPlan 
 */

CREATE INDEX IdPlan ON tPlan_x_Persona(IdPlan)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tPlan_x_Persona') AND name='IdPlan')
    PRINT '<<< CREATED INDEX tPlan_x_Persona.IdPlan >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tPlan_x_Persona.IdPlan >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tPlan_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tPlan_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tPlan_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tPlan_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdMunicipio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tSolicitudes') AND name='IdMunicipio')
BEGIN
    DROP INDEX tSolicitudes.IdMunicipio
    PRINT '<<< DROPPED INDEX tSolicitudes.IdMunicipio >>>'
END
go

/* 
 * INDEX: IdCargos 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tSolicitudes') AND name='IdCargos')
BEGIN
    DROP INDEX tSolicitudes.IdCargos
    PRINT '<<< DROPPED INDEX tSolicitudes.IdCargos >>>'
END
go

/* 
 * INDEX: IdEmpresa 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tSolicitudes') AND name='IdEmpresa')
BEGIN
    DROP INDEX tSolicitudes.IdEmpresa
    PRINT '<<< DROPPED INDEX tSolicitudes.IdEmpresa >>>'
END
go

/* 
 * INDEX: IdAreas 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tSolicitudes') AND name='IdAreas')
BEGIN
    DROP INDEX tSolicitudes.IdAreas
    PRINT '<<< DROPPED INDEX tSolicitudes.IdAreas >>>'
END
go

/* 
 * INDEX: IdMunicipio 
 */

CREATE INDEX IdMunicipio ON tSolicitudes(IdMunicipio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tSolicitudes') AND name='IdMunicipio')
    PRINT '<<< CREATED INDEX tSolicitudes.IdMunicipio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tSolicitudes.IdMunicipio >>>'
go

/* 
 * INDEX: IdCargos 
 */

CREATE INDEX IdCargos ON tSolicitudes(IdCargos)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tSolicitudes') AND name='IdCargos')
    PRINT '<<< CREATED INDEX tSolicitudes.IdCargos >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tSolicitudes.IdCargos >>>'
go

/* 
 * INDEX: IdEmpresa 
 */

CREATE INDEX IdEmpresa ON tSolicitudes(IdEmpresa)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tSolicitudes') AND name='IdEmpresa')
    PRINT '<<< CREATED INDEX tSolicitudes.IdEmpresa >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tSolicitudes.IdEmpresa >>>'
go

/* 
 * INDEX: IdAreas 
 */

CREATE INDEX IdAreas ON tSolicitudes(IdAreas)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tSolicitudes') AND name='IdAreas')
    PRINT '<<< CREATED INDEX tSolicitudes.IdAreas >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tSolicitudes.IdAreas >>>'
go

/* 
 * INDEX: IdTitulo 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTitulo_x_Persona') AND name='IdTitulo')
BEGIN
    DROP INDEX tTitulo_x_Persona.IdTitulo
    PRINT '<<< DROPPED INDEX tTitulo_x_Persona.IdTitulo >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTitulo_x_Persona') AND name='IdPersona')
BEGIN
    DROP INDEX tTitulo_x_Persona.IdPersona
    PRINT '<<< DROPPED INDEX tTitulo_x_Persona.IdPersona >>>'
END
go

/* 
 * INDEX: IdTitulo 
 */

CREATE INDEX IdTitulo ON tTitulo_x_Persona(IdTitulo)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTitulo_x_Persona') AND name='IdTitulo')
    PRINT '<<< CREATED INDEX tTitulo_x_Persona.IdTitulo >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tTitulo_x_Persona.IdTitulo >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tTitulo_x_Persona(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTitulo_x_Persona') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tTitulo_x_Persona.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tTitulo_x_Persona.IdPersona >>>'
go

/* 
 * INDEX: IdEstudio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTitulos') AND name='IdEstudio')
BEGIN
    DROP INDEX tTitulos.IdEstudio
    PRINT '<<< DROPPED INDEX tTitulos.IdEstudio >>>'
END
go

/* 
 * INDEX: IdEstudio 
 */

CREATE INDEX IdEstudio ON tTitulos(IdEstudio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTitulos') AND name='IdEstudio')
    PRINT '<<< CREATED INDEX tTitulos.IdEstudio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tTitulos.IdEstudio >>>'
go

/* 
 * INDEX: IdCargos 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos') AND name='IdCargos')
BEGIN
    DROP INDEX tTrabajos.IdCargos
    PRINT '<<< DROPPED INDEX tTrabajos.IdCargos >>>'
END
go

/* 
 * INDEX: IdAreas 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos') AND name='IdAreas')
BEGIN
    DROP INDEX tTrabajos.IdAreas
    PRINT '<<< DROPPED INDEX tTrabajos.IdAreas >>>'
END
go

/* 
 * INDEX: IdSolicitud 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos') AND name='IdSolicitud')
BEGIN
    DROP INDEX tTrabajos.IdSolicitud
    PRINT '<<< DROPPED INDEX tTrabajos.IdSolicitud >>>'
END
go

/* 
 * INDEX: IdEmpresa 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos') AND name='IdEmpresa')
BEGIN
    DROP INDEX tTrabajos.IdEmpresa
    PRINT '<<< DROPPED INDEX tTrabajos.IdEmpresa >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos') AND name='IdPersona')
BEGIN
    DROP INDEX tTrabajos.IdPersona
    PRINT '<<< DROPPED INDEX tTrabajos.IdPersona >>>'
END
go

/* 
 * INDEX: IdCargos 
 */

CREATE INDEX IdCargos ON tTrabajos(IdCargos)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos') AND name='IdCargos')
    PRINT '<<< CREATED INDEX tTrabajos.IdCargos >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tTrabajos.IdCargos >>>'
go

/* 
 * INDEX: IdAreas 
 */

CREATE INDEX IdAreas ON tTrabajos(IdAreas)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos') AND name='IdAreas')
    PRINT '<<< CREATED INDEX tTrabajos.IdAreas >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tTrabajos.IdAreas >>>'
go

/* 
 * INDEX: IdSolicitud 
 */

CREATE INDEX IdSolicitud ON tTrabajos(IdSolicitud)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos') AND name='IdSolicitud')
    PRINT '<<< CREATED INDEX tTrabajos.IdSolicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tTrabajos.IdSolicitud >>>'
go

/* 
 * INDEX: IdEmpresa 
 */

CREATE INDEX IdEmpresa ON tTrabajos(IdEmpresa)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos') AND name='IdEmpresa')
    PRINT '<<< CREATED INDEX tTrabajos.IdEmpresa >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tTrabajos.IdEmpresa >>>'
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tTrabajos(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tTrabajos.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tTrabajos.IdPersona >>>'
go

/* 
 * INDEX: IdPersona 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos_Domesticos') AND name='IdPersona')
BEGIN
    DROP INDEX tTrabajos_Domesticos.IdPersona
    PRINT '<<< DROPPED INDEX tTrabajos_Domesticos.IdPersona >>>'
END
go

/* 
 * INDEX: IdEmpresa 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos_Domesticos') AND name='IdEmpresa')
BEGIN
    DROP INDEX tTrabajos_Domesticos.IdEmpresa
    PRINT '<<< DROPPED INDEX tTrabajos_Domesticos.IdEmpresa >>>'
END
go

/* 
 * INDEX: IdPersona 
 */

CREATE INDEX IdPersona ON tTrabajos_Domesticos(IdPersona)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos_Domesticos') AND name='IdPersona')
    PRINT '<<< CREATED INDEX tTrabajos_Domesticos.IdPersona >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tTrabajos_Domesticos.IdPersona >>>'
go

/* 
 * INDEX: IdEmpresa 
 */

CREATE INDEX IdEmpresa ON tTrabajos_Domesticos(IdEmpresa)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tTrabajos_Domesticos') AND name='IdEmpresa')
    PRINT '<<< CREATED INDEX tTrabajos_Domesticos.IdEmpresa >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tTrabajos_Domesticos.IdEmpresa >>>'
go

/* 
 * INDEX: IdMunicipio 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tUsuarios') AND name='IdMunicipio')
BEGIN
    DROP INDEX tUsuarios.IdMunicipio
    PRINT '<<< DROPPED INDEX tUsuarios.IdMunicipio >>>'
END
go

/* 
 * INDEX: IdMunicipio 
 */

CREATE INDEX IdMunicipio ON tUsuarios(IdMunicipio)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tUsuarios') AND name='IdMunicipio')
    PRINT '<<< CREATED INDEX tUsuarios.IdMunicipio >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tUsuarios.IdMunicipio >>>'
go

/* 
 * INDEX: IdEmpresa 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tVisita_Solicitud') AND name='IdEmpresa')
BEGIN
    DROP INDEX tVisita_Solicitud.IdEmpresa
    PRINT '<<< DROPPED INDEX tVisita_Solicitud.IdEmpresa >>>'
END
go

/* 
 * INDEX: IdSolicitud 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tVisita_Solicitud') AND name='IdSolicitud')
BEGIN
    DROP INDEX tVisita_Solicitud.IdSolicitud
    PRINT '<<< DROPPED INDEX tVisita_Solicitud.IdSolicitud >>>'
END
go

/* 
 * INDEX: IdEmpresa 
 */

CREATE INDEX IdEmpresa ON tVisita_Solicitud(IdEmpresa)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tVisita_Solicitud') AND name='IdEmpresa')
    PRINT '<<< CREATED INDEX tVisita_Solicitud.IdEmpresa >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tVisita_Solicitud.IdEmpresa >>>'
go

/* 
 * INDEX: IdSolicitud 
 */

CREATE INDEX IdSolicitud ON tVisita_Solicitud(IdSolicitud)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tVisita_Solicitud') AND name='IdSolicitud')
    PRINT '<<< CREATED INDEX tVisita_Solicitud.IdSolicitud >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tVisita_Solicitud.IdSolicitud >>>'
go

/* 
 * INDEX: IdEtapas 
 */

IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tVisitas') AND name='IdEtapas')
BEGIN
    DROP INDEX tVisitas.IdEtapas
    PRINT '<<< DROPPED INDEX tVisitas.IdEtapas >>>'
END
go

/* 
 * INDEX: IdEtapas 
 */

CREATE INDEX IdEtapas ON tVisitas(IdEtapas)
go
IF EXISTS (SELECT * FROM sysindexes WHERE id=OBJECT_ID('tVisitas') AND name='IdEtapas')
    PRINT '<<< CREATED INDEX tVisitas.IdEtapas >>>'
ELSE
    PRINT '<<< FAILED CREATING INDEX tVisitas.IdEtapas >>>'
go

/* 
 * TABLE: tBienes_x_Microemprendimiento 
 */

ALTER TABLE tBienes_x_Microemprendimiento ADD CONSTRAINT ReftMicroemprendimientos43 
    FOREIGN KEY (IdMicroemprendimiento)
    REFERENCES tMicroemprendimientos(IdMicroemprendimiento) ON DELETE CASCADE
go


/* 
 * TABLE: tCapacidad_x_Persona 
 */

ALTER TABLE tCapacidad_x_Persona ADD CONSTRAINT ReftCapacidades44 
    FOREIGN KEY (IdCapacidad)
    REFERENCES tCapacidades(IdCapacidad) ON DELETE CASCADE
go

ALTER TABLE tCapacidad_x_Persona ADD CONSTRAINT ReftPersonas45 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: tCargos 
 */

ALTER TABLE tCargos ADD CONSTRAINT ReftTipo_Puestos6 
    FOREIGN KEY (IdTipoPuesto)
    REFERENCES tTipo_Puestos(IdTipoPuesto) ON DELETE SET NULL
go


/* 
 * TABLE: tCarnet_x_Persona 
 */

ALTER TABLE tCarnet_x_Persona ADD CONSTRAINT ReftCarnet33 
    FOREIGN KEY (IdCarnet)
    REFERENCES tCarnet(IdCarnet) ON DELETE CASCADE
go

ALTER TABLE tCarnet_x_Persona ADD CONSTRAINT ReftPersonas34 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go

ALTER TABLE tCarnet_x_Persona ADD CONSTRAINT ReftMunicipios64 
    FOREIGN KEY (IdMunicipio)
    REFERENCES tMunicipios(IdMunicipio) ON DELETE SET NULL
go


/* 
 * TABLE: tCobranzas 
 */

ALTER TABLE tCobranzas ADD CONSTRAINT ReftMicroemprendimientos47 
    FOREIGN KEY (IdMicroemprendimiento)
    REFERENCES tMicroemprendimientos(IdMicroemprendimiento) ON DELETE CASCADE
go


/* 
 * TABLE: tCursos 
 */

ALTER TABLE tCursos ADD CONSTRAINT ReftConvenios22 
    FOREIGN KEY (IdConvenio)
    REFERENCES tConvenios(IdConvenio) ON DELETE CASCADE
go

ALTER TABLE tCursos ADD CONSTRAINT ReftArea_Cursos58 
    FOREIGN KEY (IdAreaCurso)
    REFERENCES tArea_Cursos(IdAreaCurso) ON DELETE SET NULL
go


/* 
 * TABLE: tCursos_Deseados_x_Persona 
 */

ALTER TABLE tCursos_Deseados_x_Persona ADD CONSTRAINT ReftPersonas24 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go

ALTER TABLE tCursos_Deseados_x_Persona ADD CONSTRAINT ReftCursos59 
    FOREIGN KEY (IdCurso)
    REFERENCES tCursos(IdCurso) ON DELETE CASCADE
go


/* 
 * TABLE: tCursos_x_Persona 
 */

ALTER TABLE tCursos_x_Persona ADD CONSTRAINT ReftPersonas26 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go

ALTER TABLE tCursos_x_Persona ADD CONSTRAINT ReftCursos54 
    FOREIGN KEY (IdCurso)
    REFERENCES tCursos(IdCurso) ON DELETE CASCADE
go


/* 
 * TABLE: tDiscapacidad_x_Familiar 
 */

ALTER TABLE tDiscapacidad_x_Familiar ADD CONSTRAINT ReftDiscapacidades41 
    FOREIGN KEY (IdDiscapacidad)
    REFERENCES tDiscapacidades(IdDiscapacidad) ON DELETE CASCADE
go

ALTER TABLE tDiscapacidad_x_Familiar ADD CONSTRAINT ReftFamiliares42 
    FOREIGN KEY (IdFamiliar)
    REFERENCES tFamiliares(IdFamiliar) ON DELETE CASCADE
go


/* 
 * TABLE: tDiscapacidad_x_Solicitud 
 */

ALTER TABLE tDiscapacidad_x_Solicitud ADD CONSTRAINT ReftDiscapacidades49 
    FOREIGN KEY (IdDiscapacidad)
    REFERENCES tDiscapacidades(IdDiscapacidad) ON DELETE CASCADE
go

ALTER TABLE tDiscapacidad_x_Solicitud ADD CONSTRAINT ReftSolicitudes50 
    FOREIGN KEY (IdSolicitud)
    REFERENCES tSolicitudes(IdSolicitud) ON DELETE CASCADE
go


/* 
 * TABLE: tDiscapacidades 
 */

ALTER TABLE tDiscapacidades ADD CONSTRAINT ReftTipo_Discapacidades38 
    FOREIGN KEY (IdTipoDiscapacidad)
    REFERENCES tTipo_Discapacidades(IdTipoDiscapacidad) ON DELETE CASCADE
go


/* 
 * TABLE: tDiscapacidades_x_Persona 
 */

ALTER TABLE tDiscapacidades_x_Persona ADD CONSTRAINT ReftDiscapacidades39 
    FOREIGN KEY (IdDiscapacidad)
    REFERENCES tDiscapacidades(IdDiscapacidad) ON DELETE CASCADE
go

ALTER TABLE tDiscapacidades_x_Persona ADD CONSTRAINT ReftPersonas40 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: tEmpresas 
 */

ALTER TABLE tEmpresas ADD CONSTRAINT ReftIndustrias13 
    FOREIGN KEY (IdIndustria)
    REFERENCES tIndustrias(IdIndustria) ON DELETE SET NULL
go

ALTER TABLE tEmpresas ADD CONSTRAINT ReftMunicipios28 
    FOREIGN KEY (IdMunicipio)
    REFERENCES tMunicipios(IdMunicipio) ON DELETE SET NULL
go


/* 
 * TABLE: tEstudio_x_Solicitud 
 */

ALTER TABLE tEstudio_x_Solicitud ADD CONSTRAINT ReftTitulos3 
    FOREIGN KEY (IdTitulo)
    REFERENCES tTitulos(IdTitulo) ON DELETE CASCADE
go

ALTER TABLE tEstudio_x_Solicitud ADD CONSTRAINT ReftSolicitudes4 
    FOREIGN KEY (IdSolicitud)
    REFERENCES tSolicitudes(IdSolicitud) ON DELETE CASCADE
go


/* 
 * TABLE: tEtapas 
 */

ALTER TABLE tEtapas ADD CONSTRAINT ReftMicroemprendimientos46 
    FOREIGN KEY (IdMicroemprendimiento)
    REFERENCES tMicroemprendimientos(IdMicroemprendimiento) ON DELETE CASCADE
go


/* 
 * TABLE: tFamiliares 
 */

ALTER TABLE tFamiliares ADD CONSTRAINT ReftPersonas37 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: tIdioma_x_Persona 
 */

ALTER TABLE tIdioma_x_Persona ADD CONSTRAINT ReftIdiomas35 
    FOREIGN KEY (IdIdioma)
    REFERENCES tIdiomas(IdIdioma) ON DELETE CASCADE
go

ALTER TABLE tIdioma_x_Persona ADD CONSTRAINT ReftPersonas36 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: tIntereses_x_Persona 
 */

ALTER TABLE tIntereses_x_Persona ADD CONSTRAINT ReftAreas31 
    FOREIGN KEY (IdAreas)
    REFERENCES tAreas(IdAreas) ON DELETE CASCADE
go

ALTER TABLE tIntereses_x_Persona ADD CONSTRAINT ReftPersonas32 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: tMicroemprendimientos 
 */

ALTER TABLE tMicroemprendimientos ADD CONSTRAINT ReftMunicipios30 
    FOREIGN KEY (IdMunicipio)
    REFERENCES tMunicipios(IdMunicipio) ON DELETE SET NULL
go

ALTER TABLE tMicroemprendimientos ADD CONSTRAINT ReftIndustrias55 
    FOREIGN KEY (IdIndustria)
    REFERENCES tIndustrias(IdIndustria) ON DELETE SET NULL
go

ALTER TABLE tMicroemprendimientos ADD CONSTRAINT ReftPersonas56 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: tPersonas 
 */

ALTER TABLE tPersonas ADD CONSTRAINT ReftMunicipios29 
    FOREIGN KEY (IdMunicipio)
    REFERENCES tMunicipios(IdMunicipio) ON DELETE SET NULL
go


/* 
 * TABLE: tPlan_x_Empresa 
 */

ALTER TABLE tPlan_x_Empresa ADD CONSTRAINT ReftPlanes14 
    FOREIGN KEY (IdPlan)
    REFERENCES tPlanes(IdPlan) ON DELETE CASCADE
go

ALTER TABLE tPlan_x_Empresa ADD CONSTRAINT ReftEmpresas15 
    FOREIGN KEY (IdEmpresa)
    REFERENCES tEmpresas(IdEmpresa) ON DELETE CASCADE
go


/* 
 * TABLE: tPlan_x_Persona 
 */

ALTER TABLE tPlan_x_Persona ADD CONSTRAINT ReftPlanes16 
    FOREIGN KEY (IdPlan)
    REFERENCES tPlanes(IdPlan) ON DELETE CASCADE
go

ALTER TABLE tPlan_x_Persona ADD CONSTRAINT ReftPersonas17 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: tSolicitudes 
 */

ALTER TABLE tSolicitudes ADD CONSTRAINT ReftAreas9 
    FOREIGN KEY (IdAreas)
    REFERENCES tAreas(IdAreas) ON DELETE SET NULL
go

ALTER TABLE tSolicitudes ADD CONSTRAINT ReftMunicipios27 
    FOREIGN KEY (IdMunicipio)
    REFERENCES tMunicipios(IdMunicipio) ON DELETE SET NULL
go

ALTER TABLE tSolicitudes ADD CONSTRAINT ReftCargos52 
    FOREIGN KEY (IdCargos)
    REFERENCES tCargos(IdCargos) ON DELETE SET NULL
go

ALTER TABLE tSolicitudes ADD CONSTRAINT ReftEmpresas57 
    FOREIGN KEY (IdEmpresa)
    REFERENCES tEmpresas(IdEmpresa) ON DELETE SET NULL
go


/* 
 * TABLE: tTitulo_x_Persona 
 */

ALTER TABLE tTitulo_x_Persona ADD CONSTRAINT ReftTitulos18 
    FOREIGN KEY (IdTitulo)
    REFERENCES tTitulos(IdTitulo) ON DELETE CASCADE
go

ALTER TABLE tTitulo_x_Persona ADD CONSTRAINT ReftPersonas19 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: tTitulos 
 */

ALTER TABLE tTitulos ADD CONSTRAINT ReftEstudios5 
    FOREIGN KEY (IdEstudio)
    REFERENCES tEstudios(IdEstudio) ON DELETE CASCADE
go


/* 
 * TABLE: tTrabajos 
 */

ALTER TABLE tTrabajos ADD CONSTRAINT ReftCargos7 
    FOREIGN KEY (IdCargos)
    REFERENCES tCargos(IdCargos) ON DELETE SET NULL
go

ALTER TABLE tTrabajos ADD CONSTRAINT ReftAreas8 
    FOREIGN KEY (IdAreas)
    REFERENCES tAreas(IdAreas) ON DELETE SET NULL
go

ALTER TABLE tTrabajos ADD CONSTRAINT ReftSolicitudes10 
    FOREIGN KEY (IdSolicitud)
    REFERENCES tSolicitudes(IdSolicitud) ON DELETE SET NULL
go

ALTER TABLE tTrabajos ADD CONSTRAINT ReftEmpresas11 
    FOREIGN KEY (IdEmpresa)
    REFERENCES tEmpresas(IdEmpresa) ON DELETE SET NULL
go

ALTER TABLE tTrabajos ADD CONSTRAINT ReftPersonas12 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go


/* 
 * TABLE: tTrabajos_Domesticos 
 */

ALTER TABLE tTrabajos_Domesticos ADD CONSTRAINT ReftPersonas61 
    FOREIGN KEY (IdPersona)
    REFERENCES tPersonas(IdPersona) ON DELETE CASCADE
go

ALTER TABLE tTrabajos_Domesticos ADD CONSTRAINT ReftEmpresas62 
    FOREIGN KEY (IdEmpresa)
    REFERENCES tEmpresas(IdEmpresa)
go


/* 
 * TABLE: tUsuarios 
 */

ALTER TABLE tUsuarios ADD CONSTRAINT ReftMunicipios60 
    FOREIGN KEY (IdMunicipio)
    REFERENCES tMunicipios(IdMunicipio)
go


/* 
 * TABLE: tVisita_Solicitud 
 */

ALTER TABLE tVisita_Solicitud ADD CONSTRAINT ReftSolicitudes1 
    FOREIGN KEY (IdSolicitud)
    REFERENCES tSolicitudes(IdSolicitud) ON DELETE CASCADE
go

ALTER TABLE tVisita_Solicitud ADD CONSTRAINT ReftEmpresas51 
    FOREIGN KEY (IdEmpresa)
    REFERENCES tEmpresas(IdEmpresa) ON DELETE CASCADE
go


/* 
 * TABLE: tVisitas 
 */

ALTER TABLE tVisitas ADD CONSTRAINT ReftEtapas48 
    FOREIGN KEY (IdEtapas)
    REFERENCES tEtapas(IdEtapas) ON DELETE CASCADE
go


/* 
 * TRIGGER: tArea_CursosDelTrig 
 */

CREATE TRIGGER tArea_CursosDelTrig ON tArea_Cursos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE tCursos SET
            IdAreaCurso = NULL
        FROM tCursos ch, deleted
        WHERE
            ch.IdAreaCurso = deleted.IdAreaCurso

END
go

go
IF OBJECT_ID('tArea_CursosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tArea_CursosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tArea_CursosDelTrig >>>'
go


/* 
 * TRIGGER: tAreasDelTrig 
 */

CREATE TRIGGER tAreasDelTrig ON tAreas
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE tTrabajos SET
            IdAreas = NULL
        FROM tTrabajos ch, deleted
        WHERE
            ch.IdAreas = deleted.IdAreas
-- Parent Delete: SET NULL

    UPDATE tSolicitudes SET
            IdAreas = NULL
        FROM tSolicitudes ch, deleted
        WHERE
            ch.IdAreas = deleted.IdAreas
-- Parent Delete: CASCADE

    DELETE tIntereses_x_Persona
        FROM tIntereses_x_Persona ch, deleted
        WHERE ch.IdAreas = deleted.IdAreas

END
go

go
IF OBJECT_ID('tAreasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tAreasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tAreasDelTrig >>>'
go


/* 
 * TRIGGER: tCapacidadesDelTrig 
 */

CREATE TRIGGER tCapacidadesDelTrig ON tCapacidades
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tCapacidad_x_Persona
        FROM tCapacidad_x_Persona ch, deleted
        WHERE ch.IdCapacidad = deleted.IdCapacidad

END
go

go
IF OBJECT_ID('tCapacidadesDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tCapacidadesDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tCapacidadesDelTrig >>>'
go


/* 
 * TRIGGER: tCargosDelTrig 
 */

CREATE TRIGGER tCargosDelTrig ON tCargos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE tTrabajos SET
            IdCargos = NULL
        FROM tTrabajos ch, deleted
        WHERE
            ch.IdCargos = deleted.IdCargos
-- Parent Delete: SET NULL

    UPDATE tSolicitudes SET
            IdCargos = NULL
        FROM tSolicitudes ch, deleted
        WHERE
            ch.IdCargos = deleted.IdCargos

END
go

go
IF OBJECT_ID('tCargosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tCargosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tCargosDelTrig >>>'
go


/* 
 * TRIGGER: tCarnetDelTrig 
 */

CREATE TRIGGER tCarnetDelTrig ON tCarnet
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tCarnet_x_Persona
        FROM tCarnet_x_Persona ch, deleted
        WHERE ch.IdCarnet = deleted.IdCarnet

END
go

go
IF OBJECT_ID('tCarnetDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tCarnetDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tCarnetDelTrig >>>'
go


/* 
 * TRIGGER: tConveniosDelTrig 
 */

CREATE TRIGGER tConveniosDelTrig ON tConvenios
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tCursos
        FROM tCursos ch, deleted
        WHERE ch.IdConvenio = deleted.IdConvenio

END
go

go
IF OBJECT_ID('tConveniosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tConveniosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tConveniosDelTrig >>>'
go


/* 
 * TRIGGER: tCursosDelTrig 
 */

CREATE TRIGGER tCursosDelTrig ON tCursos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tCursos_x_Persona
        FROM tCursos_x_Persona ch, deleted
        WHERE ch.IdCurso = deleted.IdCurso
-- Parent Delete: CASCADE

    DELETE tCursos_Deseados_x_Persona
        FROM tCursos_Deseados_x_Persona ch, deleted
        WHERE ch.IdCurso = deleted.IdCurso

END
go

go
IF OBJECT_ID('tCursosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tCursosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tCursosDelTrig >>>'
go


/* 
 * TRIGGER: tDiscapacidadesDelTrig 
 */

CREATE TRIGGER tDiscapacidadesDelTrig ON tDiscapacidades
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tDiscapacidades_x_Persona
        FROM tDiscapacidades_x_Persona ch, deleted
        WHERE ch.IdDiscapacidad = deleted.IdDiscapacidad
-- Parent Delete: CASCADE

    DELETE tDiscapacidad_x_Familiar
        FROM tDiscapacidad_x_Familiar ch, deleted
        WHERE ch.IdDiscapacidad = deleted.IdDiscapacidad
-- Parent Delete: CASCADE

    DELETE tDiscapacidad_x_Solicitud
        FROM tDiscapacidad_x_Solicitud ch, deleted
        WHERE ch.IdDiscapacidad = deleted.IdDiscapacidad

END
go

go
IF OBJECT_ID('tDiscapacidadesDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tDiscapacidadesDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tDiscapacidadesDelTrig >>>'
go


/* 
 * TRIGGER: tEmpresasDelTrig 
 */

CREATE TRIGGER tEmpresasDelTrig ON tEmpresas
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE tTrabajos SET
            IdEmpresa = NULL
        FROM tTrabajos ch, deleted
        WHERE
            ch.IdEmpresa = deleted.IdEmpresa
-- Parent Delete: CASCADE

    DELETE tPlan_x_Empresa
        FROM tPlan_x_Empresa ch, deleted
        WHERE ch.IdEmpresa = deleted.IdEmpresa
-- Parent Delete: CASCADE

    DELETE tVisita_Solicitud
        FROM tVisita_Solicitud ch, deleted
        WHERE ch.IdEmpresa = deleted.IdEmpresa
-- Parent Delete: SET NULL

    UPDATE tSolicitudes SET
            IdEmpresa = NULL
        FROM tSolicitudes ch, deleted
        WHERE
            ch.IdEmpresa = deleted.IdEmpresa

END
go

go
IF OBJECT_ID('tEmpresasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tEmpresasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tEmpresasDelTrig >>>'
go


/* 
 * TRIGGER: tEstudiosDelTrig 
 */

CREATE TRIGGER tEstudiosDelTrig ON tEstudios
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tTitulos
        FROM tTitulos ch, deleted
        WHERE ch.IdEstudio = deleted.IdEstudio

END
go

go
IF OBJECT_ID('tEstudiosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tEstudiosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tEstudiosDelTrig >>>'
go


/* 
 * TRIGGER: tEtapasDelTrig 
 */

CREATE TRIGGER tEtapasDelTrig ON tEtapas
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tVisitas
        FROM tVisitas ch, deleted
        WHERE ch.IdEtapas = deleted.IdEtapas

END
go

go
IF OBJECT_ID('tEtapasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tEtapasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tEtapasDelTrig >>>'
go


/* 
 * TRIGGER: tFamiliaresDelTrig 
 */

CREATE TRIGGER tFamiliaresDelTrig ON tFamiliares
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tDiscapacidad_x_Familiar
        FROM tDiscapacidad_x_Familiar ch, deleted
        WHERE ch.IdFamiliar = deleted.IdFamiliar

END
go

go
IF OBJECT_ID('tFamiliaresDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tFamiliaresDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tFamiliaresDelTrig >>>'
go


/* 
 * TRIGGER: tIdiomasDelTrig 
 */

CREATE TRIGGER tIdiomasDelTrig ON tIdiomas
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tIdioma_x_Persona
        FROM tIdioma_x_Persona ch, deleted
        WHERE ch.IdIdioma = deleted.IdIdioma

END
go

go
IF OBJECT_ID('tIdiomasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tIdiomasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tIdiomasDelTrig >>>'
go


/* 
 * TRIGGER: tIndustriasDelTrig 
 */

CREATE TRIGGER tIndustriasDelTrig ON tIndustrias
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE tEmpresas SET
            IdIndustria = NULL
        FROM tEmpresas ch, deleted
        WHERE
            ch.IdIndustria = deleted.IdIndustria
-- Parent Delete: SET NULL

    UPDATE tMicroemprendimientos SET
            IdIndustria = NULL
        FROM tMicroemprendimientos ch, deleted
        WHERE
            ch.IdIndustria = deleted.IdIndustria

END
go

go
IF OBJECT_ID('tIndustriasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tIndustriasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tIndustriasDelTrig >>>'
go


/* 
 * TRIGGER: tMicroemprendimientosDelTrig 
 */

CREATE TRIGGER tMicroemprendimientosDelTrig ON tMicroemprendimientos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tBienes_x_Microemprendimiento
        FROM tBienes_x_Microemprendimiento ch, deleted
        WHERE ch.IdMicroemprendimiento = deleted.IdMicroemprendimiento
-- Parent Delete: CASCADE

    DELETE tEtapas
        FROM tEtapas ch, deleted
        WHERE ch.IdMicroemprendimiento = deleted.IdMicroemprendimiento
-- Parent Delete: CASCADE

    DELETE tCobranzas
        FROM tCobranzas ch, deleted
        WHERE ch.IdMicroemprendimiento = deleted.IdMicroemprendimiento

END
go

go
IF OBJECT_ID('tMicroemprendimientosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tMicroemprendimientosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tMicroemprendimientosDelTrig >>>'
go


/* 
 * TRIGGER: tMunicipiosDelTrig 
 */

CREATE TRIGGER tMunicipiosDelTrig ON tMunicipios
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE tSolicitudes SET
            IdMunicipio = NULL
        FROM tSolicitudes ch, deleted
        WHERE
            ch.IdMunicipio = deleted.IdMunicipio
-- Parent Delete: SET NULL

    UPDATE tEmpresas SET
            IdMunicipio = NULL
        FROM tEmpresas ch, deleted
        WHERE
            ch.IdMunicipio = deleted.IdMunicipio
-- Parent Delete: SET NULL

    UPDATE tPersonas SET
            IdMunicipio = NULL
        FROM tPersonas ch, deleted
        WHERE
            ch.IdMunicipio = deleted.IdMunicipio
-- Parent Delete: SET NULL

    UPDATE tMicroemprendimientos SET
            IdMunicipio = NULL
        FROM tMicroemprendimientos ch, deleted
        WHERE
            ch.IdMunicipio = deleted.IdMunicipio
-- Parent Delete: SET NULL

    UPDATE tCarnet_x_Persona SET
            IdMunicipio = NULL
        FROM tCarnet_x_Persona ch, deleted
        WHERE
            ch.IdMunicipio = deleted.IdMunicipio

END
go

go
IF OBJECT_ID('tMunicipiosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tMunicipiosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tMunicipiosDelTrig >>>'
go


/* 
 * TRIGGER: tPersonasDelTrig 
 */

CREATE TRIGGER tPersonasDelTrig ON tPersonas
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tTrabajos
        FROM tTrabajos ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tPlan_x_Persona
        FROM tPlan_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tTitulo_x_Persona
        FROM tTitulo_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tCursos_Deseados_x_Persona
        FROM tCursos_Deseados_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tCursos_x_Persona
        FROM tCursos_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tIntereses_x_Persona
        FROM tIntereses_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tCarnet_x_Persona
        FROM tCarnet_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tIdioma_x_Persona
        FROM tIdioma_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tFamiliares
        FROM tFamiliares ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tDiscapacidades_x_Persona
        FROM tDiscapacidades_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tCapacidad_x_Persona
        FROM tCapacidad_x_Persona ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tMicroemprendimientos
        FROM tMicroemprendimientos ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona
-- Parent Delete: CASCADE

    DELETE tTrabajos_Domesticos
        FROM tTrabajos_Domesticos ch, deleted
        WHERE ch.IdPersona = deleted.IdPersona

END
go

go
IF OBJECT_ID('tPersonasDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tPersonasDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tPersonasDelTrig >>>'
go


/* 
 * TRIGGER: tPlanesDelTrig 
 */

CREATE TRIGGER tPlanesDelTrig ON tPlanes
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tPlan_x_Empresa
        FROM tPlan_x_Empresa ch, deleted
        WHERE ch.IdPlan = deleted.IdPlan
-- Parent Delete: CASCADE

    DELETE tPlan_x_Persona
        FROM tPlan_x_Persona ch, deleted
        WHERE ch.IdPlan = deleted.IdPlan

END
go

go
IF OBJECT_ID('tPlanesDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tPlanesDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tPlanesDelTrig >>>'
go


/* 
 * TRIGGER: tSolicitudesDelTrig 
 */

CREATE TRIGGER tSolicitudesDelTrig ON tSolicitudes
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE tTrabajos SET
            IdSolicitud = NULL
        FROM tTrabajos ch, deleted
        WHERE
            ch.IdSolicitud = deleted.IdSolicitud
-- Parent Delete: CASCADE

    DELETE tVisita_Solicitud
        FROM tVisita_Solicitud ch, deleted
        WHERE ch.IdSolicitud = deleted.IdSolicitud
-- Parent Delete: CASCADE

    DELETE tEstudio_x_Solicitud
        FROM tEstudio_x_Solicitud ch, deleted
        WHERE ch.IdSolicitud = deleted.IdSolicitud
-- Parent Delete: CASCADE

    DELETE tDiscapacidad_x_Solicitud
        FROM tDiscapacidad_x_Solicitud ch, deleted
        WHERE ch.IdSolicitud = deleted.IdSolicitud

END
go

go
IF OBJECT_ID('tSolicitudesDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tSolicitudesDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tSolicitudesDelTrig >>>'
go


/* 
 * TRIGGER: tTipo_DiscapacidadesDelTrig 
 */

CREATE TRIGGER tTipo_DiscapacidadesDelTrig ON tTipo_Discapacidades
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tDiscapacidades
        FROM tDiscapacidades ch, deleted
        WHERE ch.IdTipoDiscapacidad = deleted.IdTipoDiscapacidad

END
go

go
IF OBJECT_ID('tTipo_DiscapacidadesDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tTipo_DiscapacidadesDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tTipo_DiscapacidadesDelTrig >>>'
go


/* 
 * TRIGGER: tTipo_PuestosDelTrig 
 */

CREATE TRIGGER tTipo_PuestosDelTrig ON tTipo_Puestos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: SET NULL

    UPDATE tCargos SET
            IdTipoPuesto = NULL
        FROM tCargos ch, deleted
        WHERE
            ch.IdTipoPuesto = deleted.IdTipoPuesto

END
go

go
IF OBJECT_ID('tTipo_PuestosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tTipo_PuestosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tTipo_PuestosDelTrig >>>'
go


/* 
 * TRIGGER: tTitulosDelTrig 
 */

CREATE TRIGGER tTitulosDelTrig ON tTitulos
FOR DELETE AS
BEGIN
    DECLARE
        @Rows      int

    SELECT @Rows = @@rowcount
    IF @Rows = 0
        RETURN

-- Parent Delete: CASCADE

    DELETE tEstudio_x_Solicitud
        FROM tEstudio_x_Solicitud ch, deleted
        WHERE ch.IdTitulo = deleted.IdTitulo
-- Parent Delete: CASCADE

    DELETE tTitulo_x_Persona
        FROM tTitulo_x_Persona ch, deleted
        WHERE ch.IdTitulo = deleted.IdTitulo

END
go

go
IF OBJECT_ID('tTitulosDelTrig') IS NOT NULL
    PRINT '<<< CREATED TRIGGER tTitulosDelTrig >>>'
ELSE
    PRINT '<<< FAILED CREATING TRIGGER tTitulosDelTrig >>>'
go


